package vip.xiaonuo.megvii.service.query;

import org.springframework.stereotype.Service;
import vip.xiaonuo.facedoor.modular.memberuser.entity.MemberUser;
import vip.xiaonuo.modular.devicemegvii.entity.DeviceMegvii;
import vip.xiaonuo.modular.devicemegvii.mapper.DeviceMegviiMapper;
import vip.xiaonuo.modular.devicemegvii.param.DeviceMegviiParam;
import vip.xiaonuo.modular.devicemegvii.service.DeviceMegviiService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class DeviceMegviiQueryService {

    @Resource
    private DeviceMegviiService deviceMegviiService;

    @Resource
    private DeviceMegviiMapper megviiMapper;

    /**
     * 获取所有有效的设备
     * @return
     */
    public List<DeviceMegvii> getUsefulDevice(){
        DeviceMegviiParam param = new DeviceMegviiParam();
        param.setMachStatus(3);
        return deviceMegviiService.list(param);
    }

    /**
     * 根据人员获取关联的设备
     * @param user
     * @return
     */
    public List<DeviceMegvii> getDeviceByUser(MemberUser user){
        if(user==null || user.getOrgId()==null){
            return new ArrayList<>();
        }
        return megviiMapper.getRelateDeviceByOrgId(user.getOrgId()+"");
    }

}
